package com.huang.controller;

import com.huang.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;


@Controller
@RequestMapping("/user")
public class UserController {
    @GetMapping("/t1")
    public String test1(@RequestParam("username") String name, Model model) {
        //接收前端参数
        System.out.println("接收结果:" + name);
        //返回结果传递给前端,Model
        model.addAttribute("msg", name);
        //跳转视图
        return "hello";
    }

    //前端传对象
    @GetMapping("/t2")
    public String test2(User user, Model model) {
        System.out.println(user);
        return "hello";
    }

    @GetMapping("/t3")
    public String test3(ModelMap modelMap) {

        return "hello";
    }
}
